//
//  DDDExpressBannerVC.m
//  DDDDemo
//
//  Created by mu on 2020/7/15.
//  Copyright © 2020 summer. All rights reserved.
//

#import "DDDExpressBannerVC.h"
//#import <DDDAdSdk/DDDNativeExpressBannerView.h>
#import <DDDAdSdk/DDDAdSdk.h>

@interface DDDExpressBannerVC ()<DDDNativeExpressBannerViewDelegate>
@property(nonatomic, strong) DDDNativeExpressBannerView *bannerView;
@end

@implementation DDDExpressBannerVC

- (void)viewDidLoad {
    [super viewDidLoad];
    
    switch (self.type) {
        case 0:
        {
            CGSize size = CGSizeMake(600, 90);
            CGFloat screenWidth = CGRectGetWidth([UIScreen mainScreen].bounds);
            CGFloat bannerHeigh = screenWidth / size.width*size.height;
            DDDNativeExpressBannerView *bannerView = [[DDDNativeExpressBannerView alloc]initWithFrame:CGRectMake(0, 100.0, screenWidth, bannerHeigh) rootViewController:self adType:NativeExpressBannerType_600_90 adSize:CGSizeMake(screenWidth, bannerHeigh) IsSupportDeepLink:YES];
            bannerView.delegate = self;
            self.bannerView = bannerView;
        }
            break;
        case 1:
        {
            CGSize size = CGSizeMake(640.0, 100.0);
            CGFloat screenWidth = CGRectGetWidth([UIScreen mainScreen].bounds);
            CGFloat bannerHeigh = screenWidth / size.width*size.height;
            DDDNativeExpressBannerView *bannerView = [[DDDNativeExpressBannerView alloc]initWithFrame:CGRectMake(0, 100.0, screenWidth, bannerHeigh) rootViewController:self adType:NativeExpressBannerType_640_100 adSize:CGSizeMake(screenWidth, bannerHeigh) IsSupportDeepLink:YES];
            bannerView.delegate = self;
            self.bannerView = bannerView;
        }
            break;
        case 2:
        {
            CGSize size = CGSizeMake(600.0, 150.0);
            CGFloat screenWidth = CGRectGetWidth([UIScreen mainScreen].bounds);
            CGFloat bannerHeigh = screenWidth / size.width*size.height;
            DDDNativeExpressBannerView *bannerView = [[DDDNativeExpressBannerView alloc]initWithFrame:CGRectMake(0, 100.0, screenWidth, bannerHeigh) rootViewController:self adType:NativeExpressBannerType_600_150 adSize:CGSizeMake(screenWidth, bannerHeigh) IsSupportDeepLink:YES];
            bannerView.delegate = self;
            self.bannerView = bannerView;
        }
            break;
        case 3:
        {
            CGSize size = CGSizeMake(690.0, 388.0);
            CGFloat screenWidth = CGRectGetWidth([UIScreen mainScreen].bounds);
            CGFloat bannerHeigh = screenWidth / size.width*size.height;
            DDDNativeExpressBannerView *bannerView = [[DDDNativeExpressBannerView alloc]initWithFrame:CGRectMake(0, 100.0, screenWidth, bannerHeigh) rootViewController:self adType:NativeExpressBannerType_690_388 adSize:CGSizeMake(screenWidth, bannerHeigh) IsSupportDeepLink:YES];
            bannerView.delegate = self;
            self.bannerView = bannerView;
        }
            break;
        case 4:
        {
            CGSize size = CGSizeMake(600.0, 260.0);
            CGFloat screenWidth = CGRectGetWidth([UIScreen mainScreen].bounds);
            CGFloat bannerHeigh = screenWidth / size.width*size.height;
            DDDNativeExpressBannerView *bannerView = [[DDDNativeExpressBannerView alloc]initWithFrame:CGRectMake(0, 100.0, screenWidth, bannerHeigh) rootViewController:self adType:NativeExpressBannerType_600_260 adSize:CGSizeMake(screenWidth, bannerHeigh) IsSupportDeepLink:YES];
            bannerView.delegate = self;
            self.bannerView = bannerView;
        }
            break;
        case 5:
        {
            CGSize size = CGSizeMake(600.0, 300.0);
            CGFloat screenWidth = CGRectGetWidth([UIScreen mainScreen].bounds);
            CGFloat bannerHeigh = screenWidth / size.width*size.height;
            DDDNativeExpressBannerView *bannerView = [[DDDNativeExpressBannerView alloc]initWithFrame:CGRectMake(0, 100.0, screenWidth, bannerHeigh) rootViewController:self adType:NativeExpressBannerType_600_300 adSize:CGSizeMake(screenWidth, bannerHeigh) IsSupportDeepLink:YES];
            bannerView.delegate = self;
            self.bannerView = bannerView;
        }
            break;
        case 6:
        {
            CGSize size = CGSizeMake(600.0, 400.0);
            CGFloat screenWidth = CGRectGetWidth([UIScreen mainScreen].bounds);
            CGFloat bannerHeigh = screenWidth / size.width*size.height;
            DDDNativeExpressBannerView *bannerView = [[DDDNativeExpressBannerView alloc]initWithFrame:CGRectMake(0, 100.0, screenWidth, bannerHeigh) rootViewController:self adType:NativeExpressBannerType_600_400 adSize:CGSizeMake(screenWidth, bannerHeigh) IsSupportDeepLink:YES];
            bannerView.delegate = self;
            self.bannerView = bannerView;
        }
            break;
        case 7:
        {
            CGSize size = CGSizeMake(600.0, 500.0);
            CGFloat screenWidth = CGRectGetWidth([UIScreen mainScreen].bounds);
            CGFloat bannerHeigh = screenWidth / size.width*size.height;
            DDDNativeExpressBannerView *bannerView = [[DDDNativeExpressBannerView alloc]initWithFrame:CGRectMake(0, 100.0, screenWidth, bannerHeigh) rootViewController:self adType:NativeExpressBannerType_600_500 adSize:CGSizeMake(screenWidth, bannerHeigh) IsSupportDeepLink:YES];
            bannerView.delegate = self;
            self.bannerView = bannerView;
        }
            break;
        case 8:
        {
            CGSize size = CGSizeMake(640, 100.0);
            CGFloat screenWidth = CGRectGetWidth([UIScreen mainScreen].bounds);
            CGFloat bannerHeigh = screenWidth / size.width*size.height;
            DDDNativeExpressBannerView *bannerView = [[DDDNativeExpressBannerView alloc]initWithFrame:CGRectMake(0, 100.0, screenWidth, bannerHeigh) rootViewController:self adType:NativeExpressBannerType_64X10All adSize:CGSizeMake(screenWidth, bannerHeigh) IsSupportDeepLink:YES];
            bannerView.delegate = self;
            self.bannerView = bannerView;
        }
            break;
        case 9:
        {
            CGSize size = CGSizeMake(640, 100.0);
            CGFloat screenWidth = CGRectGetWidth([UIScreen mainScreen].bounds);
            CGFloat bannerHeigh = screenWidth / size.width*size.height;
            DDDNativeExpressBannerView *bannerView = [[DDDNativeExpressBannerView alloc]initWithFrame:CGRectMake(0, 100.0, screenWidth, bannerHeigh) rootViewController:self adType:NativeExpressBannerType_64X10Image adSize:CGSizeMake(screenWidth, bannerHeigh) IsSupportDeepLink:YES];
            bannerView.delegate = self;
            self.bannerView = bannerView;
        }
            break;
        case 10:
        {
            CGSize size = CGSizeMake(640, 100.0);
            CGFloat screenWidth = CGRectGetWidth([UIScreen mainScreen].bounds);
            CGFloat bannerHeigh = screenWidth / size.width*size.height;
            DDDNativeExpressBannerView *bannerView = [[DDDNativeExpressBannerView alloc]initWithFrame:CGRectMake(0, 100.0, screenWidth, bannerHeigh) rootViewController:self adType:NativeExpressBannerType_64X10TextImage adSize:CGSizeMake(screenWidth, bannerHeigh) IsSupportDeepLink:YES];
            bannerView.delegate = self;
            self.bannerView = bannerView;
        }
            break;
            
        default:
            break;
    }
    [self.view addSubview:self.bannerView];
    [self.bannerView loadAdData];
}

#pragma mark-- DDDNativeExpressBannerViewDelegate
/// 广告加载成功
- (void)nativeExpressBannerAdViewDidLoad {
    NSLog(@"%s",__func__);
}

/// 广告加载失败
/// @param errorCode 错误码
- (void)nativeExpressBannerAdViewLoadFailWithError:(NSInteger )errorCode {
    NSLog(@"%s",__func__);
    NSLog(@"summer--%ld",errorCode);
}


/// 广告展现成功
- (void)nativeExpressBannerAdViewRenderSuccess {
    NSLog(@"%s",__func__);
}

/// 广告无法呈现
/// @param errorCode 错误码
- (void)nativeExpressBannerAdViewRenderFailWithError:(NSInteger)errorCode {
    NSLog(@"%s",__func__);
}

/**
 有新的广告调用此方法
 */
- (void)nativeExpressBannerAdViewWillBecomVisible {
    NSLog(@"%s",__func__);
}

/// 点击广告时回调
- (void)nativeExpressBannerAdViewDidClick {
    NSLog(@"%s",__func__);
}
/// 当用户单击不喜欢按钮并选择不喜欢的原因时，将调用此方法。
/// @param filterwords 不喜欢原因数组
- (void)nativeExpressBannerAdViewDislikeWithReason:(NSArray<NSString *> *_Nullable)filterwords {
    NSLog(@"%s",__func__);
    for (NSString *name in filterwords) {
        NSLog(@"summer--%@",name);
    }
    
}
/// 此方法在关闭另一个控制器时调用
- (void)nativeExpressBannerAdViewDidCloseOtherController {
    NSLog(@"%s",__func__);
}
@end
